<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
</style>
<script>
    import Vue from 'vue';
    import { mapMutations, mapActions, mapState } from 'vuex';
	export default {
        methods: {
          ...mapActions(['get_init']),
          init(payload){
              return Promise.all([this.get_init(payload)])
          }
        },
		globalData: {
			statusBarHeight: 0,  	// 状态栏高度
			navHeight: 0,			// 导航栏高度
			winHeight: 0,         	// 屏幕高度
			capHeight: 0,			// 胶囊高度
			safeArea: 0,			// 安全区域高度
		},
		onLaunch: function() {
			let that = this
            // 获取设备信息
            // #ifdef MP-WEIXIN
            let menuButton = uni.getMenuButtonBoundingClientRect();
			uni.getSystemInfo({
				success: function(res) {
					let data = that.globalData
					data.statusBarHeight = res.statusBarHeight;
					data.navHeight = menuButton.height + (menuButton.top - res.statusBarHeight) * 2; 
					data.winHeight = res.windowHeight;
					data.capHeight = menuButton.height;
					data.safeArea = res.safeArea.height ? res.safeArea.height : 0 - res.statusBarHeight - data.navHeight;
                    that.$store.dispatch('init/get_data', {
                        statusBarHeight: data.statusBarHeight,
                        navHeight: data.navHeight,
                        capHeight: data.capHeight,
                        safeArea: data.safeArea
                    })
				}
			})
            // #endif	
            // #ifdef MP-ALIPAY
                uni.getSystemInfo({
                    success:function(res){
                        that.$store.dispatch('init/get_data', {
                            statusBarHeight: res.statusBarHeight,
                            navHeight: res.titleBarHeight,
                            capHeight: res.statusBarHeight,
                            safeArea: res.windowHeight
                        })
                    }
                })
            // #endif
			// console.log('App Launch')
		},
		onShow: function() {
            uni.hideTabBar();
			// console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide')
		},
	}
</script>

<style>
	* {
		padding: 0;
		margin: 0;
	}
	page {
		background-color: #f8f8fb;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}
    input {
        background: transparent;
    }
</style>
